package com.wy.crl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wy.base.AbstractCrl;
import com.wy.model.User;
import com.wy.result.Result;
import com.wy.service.UserService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * @apiNote 用户API
 * @author ParadiseWY
 * @date 2019年10月11日
 */
@Api(tags = "用户API")
@RequestMapping("user")
@RestController
public class UserCrl extends AbstractCrl<User> {

	@Autowired
	private UserService userService;

	@ApiOperation("登录")
	@GetMapping("login")
	public Result<?> login(@ApiParam("账户,可以是用户名,手机号,邮箱,身份证号") @RequestParam String account,
			@RequestParam String password) {
		return Result.ok(userService.login(account, password));
	}
	
	@ApiOperation("退出")
	@GetMapping("logout")
	public Result<?> logout(@ApiParam("用户登录时的token") @RequestParam String token) {
		return Result.ok(userService.logout(token));
	}
}